package com.springmq.mq.thread;

/**
 * @ClassName : ThreadType
 * @Author : lby
 * @Date: 2021/2/1 10:36
 * @Description : 线程状态测试
 */

import lombok.extern.slf4j.Slf4j;

/**
 * 线程的状态
 * 1. 创建线程 2.就绪状态 3.运行状态 4. 结束状态
 * @author Dragon
 */
@Slf4j
public class ThreadType implements Runnable {
    /**
     * 线程状态
     */
    private Boolean threadState=true;
    private Integer size=20;

    @Override
    public void run() {
        while (threadState){
            log.info("线程正在运行:{}",threadState);
        }
    }

    /**
     * 线程终止测试
     * @param args
     */
    public static void main(String[] args) {
        ThreadType threadType = new ThreadType();
        new Thread(threadType).start();
        for (int i = 0; i <threadType.size; i++) {
            log.info("线程当前状态:{}",i);
            if (i==10){
                threadType.threadState=false;
            }
        }
    }
}
